<?php
//@khn 物流状态回写AX类
class ome_UpdateAXStatus{
    //回写AX状态
    function UpdateAXStatus($shop_bn,$delivery_bn,$order_bn,$logi_no,$logi_name)
    {
        header("Content-type: text/html; charset=utf-8");
        try
        {
            date_default_timezone_set("PRC");
            ini_set('soap.wsdl_cache_enabled', "0"); //关闭wsdl缓存
                ini_set('default_socket_timeout', 5000); //timeout
            $param = array
            (
                'SourceId'=>$shop_bn,
                'DeliveryNoteNo'=>$delivery_bn,
                'OrderNo'=>$order_bn,
                'CourierNumber'=>$logi_no,
                'ExpressCompany'=>$logi_name
            );
	        //过滤参数获取不完整
            if($param['SourceId']=='' || $param['DeliveryNoteNo']=='' || $param['OrderNo']=='' || $param['CourierNumber']==''|| $param['ExpressCompany']=='')
            {
                error_log(date('Y-m-d H:i:s') . '发送数据/' . var_export($param, true), 3, DATA_DIR . '/error_UpdateAXStatus_' . date('Y-m-d') . '.log');
                exit();
            }

            if(WITH_QIMEN){
                $res=kernel::single('erpapi_rpc_qimen')->call('PublishDeliveryInfo',$param);
                $res=json_decode($res,1);
            }else{
                $client = new SoapClient(WEBSERVICE_URL);
                $res = $client->__soapCall('PublishDeliveryInfo',array('parameters'=>$param));
            }
            
            
            error_log(date('Y-m-d H:i:s') . '发送数据/' . var_export($param, true) . '返回数据/' . var_export($res, true), 3, DATA_DIR . '/UpdateAXStatus_' . date('Y-m-d') . '.log');
            return true;
        }
        catch (Exception $e)
        {
            $msg=$e->getMessage();
            error_log(date('Y-m-d H:i:s') . 'catch/' . $msg, 3, DATA_DIR . '/error_UpdateAXStatus_' . date('Y-m-d') . '.log');
        }
    }
}
